package com.guoguo.sincemusic.ui.common.Adapter

import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter

/**
 * viewPage2 的adapter
 *  用来制作 tabs 标签页面
 * @author GuoGuo
 * @date 2021/12/21
 */
class ViewPage2Adapter(private val fragments: MutableList<Fragment>, fragment: Fragment) :
    FragmentStateAdapter(fragment) {

    override fun getItemCount() = fragments.size

    override fun createFragment(position: Int): Fragment {
        val fragment = fragments[position]
        fragment.arguments = Bundle().apply {
            putInt("ARG_OBJECT", position + 1)
        }
        return fragment
    }
}
